import os, sys, code, getpass

#append path
#C:\\google_appengine
#C:\\google_appengine\lib\webob
#C:\\google_appengine\lib\django
#C:\\google_appengine\lib\yaml\lib
gae_path = 'C:\\google_appengine'
sys.path = [gae_path,
            os.path.join(gae_path,'lib','webob'),
            os.path.join(gae_path,'lib','django'),
            os.path.join(gae_path,'lib','yaml','lib')] + sys.path

from google.appengine.ext            import db
from google.appengine.ext.remote_api import remote_api_stub

def auth_func():
    return raw_input('Username:'), getpass.getpass('Password:')

if len(sys.argv) < 2:
    print 'Usage: %s app_id [host]' % (sys.argv[0],)
else:
    arg2 = len(sys.argv) > 2 and sys.argv[2]
    app_id = sys.argv[1]
    host = 'localhost:9999' if arg2 else '%s.appspot.com' % app_id
    
    remote_api_stub.ConfigureRemoteDatastore(app_id, '/remote_api', auth_func, host)
    code.interact('App Engine interactive console for %s%s' % (app_id,' @local' if arg2 else ''), None, locals())
